package com.gemme.gemme.view;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gemme.gemme.R;
import com.gemme.gemme.home.BrandBean;
import com.gemme.gemme.home.BrandListActivity;

public class SingleBrandView extends RelativeLayout {
    private Context context;
    public SingleBrandView(Context context) {
        this(context,null);
    }

    public SingleBrandView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SingleBrandView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    TextView cn_name;
    TextView eg_name;
    ImageView bigpicture;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.single_brand_view,this);

        cn_name = findViewById(R.id.cn_name);
        eg_name = findViewById(R.id.eg_name);
        bigpicture = findViewById(R.id.bigpicture);
    }

    public void setData(BrandBean.DataBean dataBean) {
        try {
            String brandName = dataBean.getBrandName();
            cn_name.setText(brandName);
            Glide.with(context).load(dataBean.getBrandLogo()).into(bigpicture);

            setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(getContext(), BrandListActivity.class);
                    intent.putExtra("brandName",dataBean.getBrandName());
                    intent.putExtra("brandLogo",dataBean.getBrandLogo());
                    context.startActivity(intent);
                }
            });

        }catch (Exception e){

        }
    }
}
